#pragma once
#include "IInput.h"
#include <map>
#include <vector>
POCELAIN_NAMESPACE_BEGIN
class POCELAIN_EXPORT InputGLFW: public IInput
{
public:
    explicit InputGLFW(GLFWwindow *window);
    virtual void update()override;

    //TODO : Not perfect implement
    virtual bool anyKey()override;
    virtual bool getKey(EKeyCode code)override;
    virtual bool getKeyDown(EKeyCode code)override;
    virtual bool getKeyUp(EKeyCode code)override;

    virtual bool getButton(std::string button)override;
    virtual Real getAxis(std::string axis)override;

    virtual Vector2 getMousePosition()override;
    virtual Vector2 getMousePositionDelta()override;
    virtual Vector2 getMouseScrollDelta()override;
    virtual Vector2 getWindowSize()override;

    virtual void setCursorState(ECursorState state)override;
private:
    std::vector<int> ala;
    GLFWwindow *mWindow;
    bool mAnyKey=false;
    Vector2 mCursor;
    Vector2 mLastCursor;
    void refreshKeyState();

    static Vector2 smScrollDelta ;
    static Vector2 smWindowSize ;
    static int smMapKeyCode2GLFWKeyNum[int(EKeyCode::KeyCodeEnd)];
    static int smMapGLFWKeyNum2KeyCode[GLFW_KEY_LAST+1];
    static int smMapGLFWMouseKeyNum2KeyCode[GLFW_MOUSE_BUTTON_LAST+1];
    static EKeyState smButtonStateCache[int(EKeyCode::KeyCodeEnd)];
    static bool smHasInitKeyCodeMap;
    static void initKeyCodeMap();
    static int keyCodeTranform(EKeyCode key);
};
POCELAIN_NAMESPACE_END
